$(document).ajaxError(function(event,xhr,options,exc){
    if(xhr.status==400){
        alert("参数校验失败");
    }
});

$(document).ajaxError(function(event,xhr,options,exc){
    if(xhr.status==401){
        alert("未登录");
        location.assign("/blog_login.html");
    }
});

$(document).ajaxSend(function(e,xhr,opt){
   xhr.setRequestHeader("user_token",localStorage.getItem("user_token"));
});


function getUserInfo(url) {
    $.ajax({
        url: url,
        type: "get",
        success: function (result) {
            if (result != null && result.code == 200 && result.msg == "成功" && result.data != null) {
                $(".container .left .card h3").text(result.data.username);
                $(".container .left .card a").attr("herf", result.data.githubUrl);
            }
        }
    })
}


function logout() {
    localStorage.removeItem("user_token");
    localStorage.removeItem("user_id");
    location.assign("/blog_login.html");
}



